package com.huwaiwai.nio.utils;

import java.nio.ByteBuffer;

/**
 * nio 学习时使用的工具类
 * Created by huweiwei on 2017/4/20.
 */
public class ChannelUtils {

    public static String read(ByteBuffer buf){
        StringBuffer sb = new StringBuffer();
        buf.flip();
        while (buf.hasRemaining()) {
            sb.append((char) buf.get());
        }
        return sb.toString();
    }

}
